package exam.axhu.junit;

import static org.junit.Assert.*;

import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import exam.axhu.entity.Admin;
import exam.axhu.entity.Teacher;
import exam.axhu.service.AdminService;

public class AdminTest {
private static AdminService adminService;
	
	@BeforeClass
	public static void setUpBeforeClass() throws Exception{
		try {
			ApplicationContext act = new ClassPathXmlApplicationContext("beans.xml");
			adminService =(AdminService) act.getBean("adminServiceImpl");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	
	@Test
	public void save() {
		if(adminService.save(new Admin("admin","123456"))==0)
			System.out.println("already have!");
	
	}
	
	
	
	@Test
	public void delete() {
		adminService.delete("admin");
	}
	
	@Test
	public void find() {
		Admin em = adminService.findByID("admin1");
		if (em!=null)
			System.out.println(em.getPassword());
		else System.out.println("not found");
	}
	
}
